from typing import Optional, List

from fastapi import UploadFile, File
from pydantic import BaseModel


class ReviewsImagesRequest(BaseModel):
    reviews_id: Optional[str]
    is_release: Optional[bool]
    primary_image: Optional[str]
    reviews_images: Optional[List[str]]


class ReviewsListQueryModel(BaseModel):
    user_id: Optional[str]
    group_id: Optional[str]
    keyword: Optional[str]
    is_hot: bool = False
    page_num: int = 1
    page_size: int = 10


class ReviewsLikerRequest(BaseModel):
    reviews_id: Optional[str]
    user_id: Optional[str]
    liker_num: Optional[int]
    method: Optional[str]       # plus | minus


class ReviewsViewModel(BaseModel):
    reviews_id: Optional[str]
    reviews_title: Optional[str]
    reviews_content: Optional[str]
    primary_image: Optional[str]
    reviews_images: Optional[list[str]]
    user_id: Optional[str]
    reviews_author: Optional[str]
    reviews_avatar: Optional[str]
    reviews_group_code: Optional[int]
    group_chain: Optional[str]
    is_hot: Optional[bool]
    mark: Optional[float]
    is_release: Optional[bool]
    release_time: Optional[str]
    create_time: Optional[str]
    last_modify_time: Optional[str]
    liker_num: Optional[int]
    del_flag: Optional[bool]


class ReviewsFormModel(BaseModel):
    reviews_title: Optional[str]
    reviews_content: Optional[str]
    user_id: Optional[str]
    reviews_author: Optional[str]
    reviews_avatar: Optional[str]
    reviews_group_code: Optional[int]
    group_chain: Optional[str]
    liker_num: Optional[int]
    mark: Optional[float]
    is_release: Optional[bool]


class UploadReviewsImageModel(BaseModel):
    user_id: Optional[str]
    reviews_image_files: List[UploadFile] = File(...)
    reviews_author: Optional[str]
    reviews_avatar: Optional[str]


class ReviewsListResponseModel(BaseModel):
    rows: List = []
    page_num: int
    page_size: int
    total: int
    has_next: bool


class ReviewsPageObjectResponse(BaseModel):
    """
    菜单管理列表分页查询返回模型
    """
    rows: List = []
    page_num: int
    page_size: int
    total: int
    has_next: bool
